(() => {
  let ele = {};
  ele.wangqi_bot = $("#wangqi_bot");
  ele.top_img = $("#top_img");
  let list = [];

  window.onload = () => {
    initList();
  };
  function initList() {
    let token = getCookie("token");
    ajax({
      method: "get",
      url: API_PATH.RANK,
      header: {
        Authorization: token,
      },
      success: (res) => {
        list = res.data;
        initTampt();
      },
      error: (err) => {
        // openTips(err.msg);
      },
    });
  }

  function initTampt() {
    // 点击返回
    ele.top_img.onclick = () => {
      history.back();
    };
    // 获取携带或来的参数
    let newList = list
      .map((item, index) => {
        if (index >= 3) {
          console.log(111);
          return ` <div class="wangqi_son">
        <div class="left">
          <div class="bg">
           <div class="bg_yuan">${index + 1}</div>
          </div>
          <img
            class="left_img"
            src="${
              item.info && item.info.head_pic
                ? IMG_DOMAIN + item.info.head_pic
                : item.info.sex == 1
                ? "http://img.qxgs.cc/tiantianlaishouzu/img/my/tx1.png"
                : "http://img.qxgs.cc/tiantianlaishouzu/img/my/tx2.png"
            }"
            alt=""
          />
          <p>${item.info ? item.info.nick_name : "普通用户"}</p>
        </div>
        <div class="right">
          <img src="http://img.qxgs.cc/tiantianlaishouzu/img/investmentIn_mines/jinbi.png" alt="" />
          <span>${item.max_wk}个</span>
        </div>
      </div>`;
        } else {
          return ` <div class="wangqi_son">
      <div class="left">
        <div class="bg">
          <img src="http://img.qxgs.cc/tiantianlaishouzu/img/investmentIn_mines/${index + 1}.png" alt="" />
          <!-- <div class="bg_yuan">5</div> -->
      </div>
        <img
          class="left_img"
          src="${
            item.info && item.info.head_pic
              ? IMG_DOMAIN + item.info.head_pic
              : item.info.sex == 1
              ? "http://img.qxgs.cc/tiantianlaishouzu/img/my/tx1.png"
              : "http://img.qxgs.cc/tiantianlaishouzu/img/my/tx2.png"
          }"
          alt=""
        />
        <p>${item.info ? item.info.nick_name : "普通用户"}</p>
      </div>
      <div class="right">
        <img src="http://img.qxgs.cc/tiantianlaishouzu/img/investmentIn_mines/jinbi.png" alt="" />
        <span>${item.max_wk}个</span>
      </div>
    </div>`;
        }
      })
      .join(" ");
    ele.wangqi_bot.innerHTML = newList;
  }
})();
